<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link href="/static/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/static/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/static/css/plugins/footable/footable.core.css" rel="stylesheet">

  <link rel="stylesheet" href="/static/css/plugins/sweetalert/sweetalert2.min.css">
    <link href="/static/css/animate.css" rel="stylesheet">
    <link href="/static/css/style.css?v=4.1.0" rel="stylesheet">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/plugins/sweetalert/sweetalert2.js"></script>


</head>
<body>
<h2 class="text-navy text-center">添加角色</h2>
<form id="role_fm">
    {{form.hidden_tag()}}
    <div class="col-md-12">
        <div class="form-group">
            <label class="col-sm-3 control-label">{{form.role_name.label}}</label>
            <div class="col-sm-9">
                {{form.role_name}}
                <br>
                <span class="help-block m-b-none"> {{form.role_name.errors.0}}</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">{{form.role_type.label}}</label>
            <div class="col-sm-9">
                {{form.role_type}}
                <br>
                <span class="help-block m-b-none"> {{form.role_type.errors.0}}</span>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">{{form.parent_role.label}}</label>
            <div class="col-sm-9">
                {{form.parent_role}}
                <br>
                <span class="help-block m-b-none"> {{form.parent_role.errors.0}}</span>
            </div>
        </div>
        <div class="col-sm-4 col-sm-offset-4 form-group" style="text-align:center">
            <button class=" btn btn-primary " onclick="update_role()">保存</button>
        </div>
    </div>
</form>

<script>
    //更新角色信息
    function update_role() {
        //发起ajax请求
        $.ajax({
            type: "POST",//方法类型
            dataType: "json",//预期服务器返回的数据类型
            //服务地址
            url: "{{ url_for('admin.update_role') }}",
            //关闭异步模式
            async:false,
            //序列化表单
            data: $('#role_fm').serialize(),
            success: function (result) {
                if (result.success == true) {
                    parent.parent.success("保存角色信息成功！");
                }
                if(result.success == false){
                    parent.parent.failed("保存角色信息失败！");
                };
            }
        });

    }

</script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/plugins/footable/footable.all.min.js"></script>
</body>
</html>